package Tests;

import static org.junit.Assert.*;
import static org.junit.Assert.fail;

import org.junit.Test;

import fightSequencing.Fight;
import fightSequencing.FightSequencer;

import EventHandling.CombatEventHandler;

public class ACombatEventHandlerShould {
	
	CombatEventHandler handler = new CombatEventHandler();

	String testMessage = "[19:35:32] Herne's Safety Off hits (Normal) Archaean Seismocratist for 182 physical damage. (Normal)";
	String testMessage2 = "[19:35:39] Archaean Seismocratist's Attack hits (Normal) you for 2375 magical damage. (Normal)";
	String testMessage3 = "[19:35:33] Your Blade Torrent hits (Normal) Archaean Seismocratist for 152 physical damage. (Blocked)";
	
	@Test
	public void correctlyManageAndHandleACorrectlyFormattedTextMessage() {

		handler.handle(testMessage);
		assertEquals("Archaean Seismocratist", FightSequencer.listOfCurrentFights.get(0).getMob().getName());
		assertEquals("Herne", FightSequencer.listOfCurrentFights.get(0).getGroup().get(0).getName());
		FightSequencer.listOfCurrentFights.clear();
		handler = null;
	}
	
	@Test
	public void correctlyStripATestMessageWithABossAsSubject() {
		FightSequencer.listOfCurrentFights.clear();
		handler.handle(testMessage2);
		assertEquals("Rellyk", FightSequencer.listOfCurrentFights.get(0).getGroup().get(0).getName());
		assertEquals(2375, FightSequencer.listOfCurrentFights.get(0).getGroup().get(0).getCurrentDamageTaken(), 0);
		FightSequencer.listOfCurrentFights.clear();
		handler = null;
	}
	
	@Test
	public void givenAPopulatedFightSequenceShouldAddANewPlayer() {
		handler.handle(testMessage);
		handler.handle(testMessage2);
		handler.handle(testMessage3);
		assertEquals("Herne", FightSequencer.listOfCurrentFights.get(0).getGroup().get(0).getName());
		assertEquals("Rellyk", FightSequencer.listOfCurrentFights.get(0).getGroup().get(1).getName());
	}
}
